-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
K8s metadata from falco #1606
K8s metadata from falco #1606
Conversation
37d2d6e
to
940dd28
Compare
This commit reenables Falco's full build in order to enable us using the container engines to extract k8s metadata from container labels. A feature flag has been added in order to maintain the current behaviour of using our custom engine that just grabs container ID from cgroups or default to using Falco's engines that also capture metadata by querying runtimes. In order to simplify and (somewhat) abstract extraction of fields, a new K8s class has been created. Unfortunately, due to how Falco works, we still need to pass in the inspector to the constructor and the events need to be forwarded to the getters for the metadata. By default only CRI, CRI-O and containerd engines are used (all 3 of them share the same API), but a couple configuration flags have been added to enable using docker and podman in case we need them at some point in time.
707b724
to
b623e54
Compare
collector/lib/K8s.h
Outdated
|
||
inline std::string_view GetContainerLabel(const std::string& container_id, const std::string& label) { | ||
const auto container = inspector_->m_container_manager.get_container(container_id); | ||
if (container == nullptr || container->m_labels.count(label) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using count
seems inefficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's what Falco does so I didn't pay it too much care, count
returns either 1 or 0 since map
doesn't allow duplicate keys (see https://en.cppreference.com/w/cpp/container/map/count)
I could change it to find
, but I think the slowest operation will be creating the copy of the string either way
(And as I write this comment I realize there are some changes missing here that are in #1614, I'll add them back and rebase the other 2 PRs)
I don't think |
604e236
to
d7fb9bc
Compare
* Add k8s based tests for namespace metadata (#1615)
Description
As part of the ROX-22981 issue, requiring collector to filter what that is sent depending on k8s metadata like the namespace a given container belongs to, this PR re-enables Falco's full build, allowing for the container engines to be used again. By doing this, we can now query the CRI, CRI-O and containerd sockets for additional container information and get the namespace from that, as well as additional label information that might come in handy in the near future. Also added configuration options for falco's docker and podman container engine information gathering, since these might could be helpful for either testing or if we need to support native workloads.
Checklist
Automated testing
If any of these don't apply, please comment below.
Testing Performed
Manually tested the changes alongside the newly implemented k8s based tests.